import Vue from 'vue'
const admin = {
    // 获取列表
    adminList: function adminList(ip, postdata) {
        return Vue.http.post(ip, postdata).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body)
            } else {
                return Promise.reject(response.data.message)
            }
        })
    },
    // 注册
    adminRegister: function adminRegister(ip, postdata) {
        // console.log(postdata, ip)
        return Vue.http.post(ip, postdata).then(response => {
            // console.log('end')
            if (response.status === 200) {
                return Promise.resolve(response.body)
            } else {
                return Promise.reject(response.data.message)
            }
        })
    },
    // 修改密码
    adminUpwd: function adminUpwd(ip, postdata) {
        return Vue.http.post(ip, postdata).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body)
            } else {
                return Promise.reject(response.data.message)
            }
        })
    },
    // 重置密码
    adminReset: function adminReset(ip, postdata) {
        return Vue.http.post(ip, postdata).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body)
            } else {
                return Promise.reject(response.data.message)
            }
        })
    },
    // 删除管理员
    adminDel: function adminDel(ip, postdata) {
        var ipStr = ip + "/" + postdata.opid + "/" + postdata.id
        return Vue.http.get(ipStr, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body)
            } else {
                return Promise.reject(response.data.message)
            }
        })
    }
}

export default admin